package com.zhuge_new.Adapter;

import android.app.Activity;
import android.content.Context;
import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.zhuge_new.R;
import com.zhuge_new.bean.CardListBean;
import com.zhuge_new.share.BaseHttp;
import com.zhuge_new.untils.Tailuntils;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2018/8/29.
 */

public class CardListAdapter extends BaseQuickAdapter<CardListBean.CreditcardsBean,BaseViewHolder> {

    private List<CardListBean.CreditcardsBean> creditcardsBeanList = new ArrayList<>();

    private Context context;
    private String identityCard;


    public CardListAdapter(@Nullable Activity context, List<CardListBean.CreditcardsBean> data) {

        super(R.layout.item_home, data);

        this.creditcardsBeanList = data;

        this.context = context;
    }


    @Override
    public int getItemCount() {

        return creditcardsBeanList.size()+getHeaderLayoutCount()+getFooterLayoutCount();
    }

    @Override
    protected void convert(BaseViewHolder helper, CardListBean.CreditcardsBean item) {

        helper.setText(R.id.bank_name,item.getBank());

        ImageView ivCard = helper.getView(R.id.bank_top);

        Glide.with(context).load(BaseHttp.baseImg1+item.getLogoUrl()).into(ivCard);

        helper.setText(R.id.bill,item.getBillamount());

        helper.setText(R.id.person_name,item.getName());

        for (int i=0; i<creditcardsBeanList.size();i++){
            identityCard = Tailuntils.getCardTailNum(item.getCreditcard());
        }
        helper.setText(R.id.bank_tail,identityCard);

        helper.addOnClickListener(R.id.tv_pepay);
        helper.addOnClickListener(R.id.home_bill);

    }

}
